<template>
 <div>
    <!--导航栏-->
    <topnav v-bind:title="navTitle"></topnav>
    <ordercon v-if="navTitle==='外卖订单'"></ordercon>
    <running v-else-if="navTitle==='跑腿'"></running>
    <person v-else-if="navTitle==='我的'"></person>
    <tabbar v-on:listenToChild="showMytitle" class="footer"></tabbar>
 </div>
</template>
<script>
import topnav from '@/components/topnav'
import tabbar from '@/components/tabbar'
import ordercon from '@/pages/orderform/ordercon'
import person from '@/pages/person/person'
import running from '@/pages/running/running'
import Router from '../router'
export default {
  name: 'index',
  components: {
    topnav,
    tabbar,
    ordercon,
    person,
    running
  },
  data () {
    return {
      navTitle: '外卖订单'
    }
  },
  methods: {
    showMytitle: function (navTitle) {
      this.navTitle = navTitle
    },
    checklogin () {
      let name = localStorage.getItem('currentUser_name')
      if (name == null || name === '') {
        this.$message({
          message: '您没有登录，请先登录',
          type: 'error'
        })
        Router.push('/')
      }
    }
  },
  created: function () {
    this.checklogin()
  }
}
</script>
<style lang="stylus">
.footer
   position fixed
   bottom 0
   z-index 100
</style>
